package zdsoft.nbfsc.task;

import sense.vitality.ioc.SenseInjection;
import sense.vitality.protocol.ObjectResult;
import sense.vitality.protocol.Stuff;
import sense.vitality.security.Authentication;
import sense.vitality.security.Passport;
import sense.vitality.task.IntellTask;
import sense.vitality.verify.Parameter;
import sense.vitality.verify.Verify;
import sense.vitality.verify.VerifyCategory;


/**
 *
 * @author elegance
 */
public class CreateTableTask extends IntellTask {

    @SenseInjection
    private Authentication authentication;

    @Override
    protected Stuff execute(Stuff request) {
        Param param = request.getParameter();
        ObjectResult<Passport> orp = authentication.login(param.getEmail(), param.getMobileNumber(), param.getIdent(), param.getPassword());
        Stuff resp = request.instanceResponse(orp.getResult());
        if (resp.getResult().isSuccess()) {
            resp.setTargetObject(orp.getTargetObject());
        }
        return resp;
    }

    public static class Param extends Parameter {

        @Verify
        private String password;
        @Verify(VerifyCategory.PICK)
        private String ident;
        @Verify(VerifyCategory.PICK)
        private String email;
        @Verify(VerifyCategory.PICK)
        private String mobileNumber;

        /**
         * @return the password
         */
        public String getPassword() {
            return password;
        }

        /**
         * @param password the password to set
         */
        public void setPassword(String password) {
            this.password = password;
        }

        /**
         * @return the ident
         */
        public String getIdent() {
            return ident;
        }

        /**
         * @param ident the ident to set
         */
        public void setIdent(String ident) {
            this.ident = ident;
        }

        /**
         * @return the email
         */
        public String getEmail() {
            return email;
        }

        /**
         * @param email the email to set
         */
        public void setEmail(String email) {
            this.email = email;
        }

        /**
         * @return the mobileNumber
         */
        public String getMobileNumber() {
            return mobileNumber;
        }

        /**
         * @param mobileNumber the mobileNumber to set
         */
        public void setMobileNumber(String mobileNumber) {
            this.mobileNumber = mobileNumber;
        }
    }

}
